% Plots of Tversky & Kahneman (1992) Value and Weighting Functions

% Parameters for value function
alpha = 0.5;   % Diminishing sensitivity for gains
lambda = 2.5;  % Loss aversion coefficient

% Parameters for weighting function
delta_values = [0.4, 0.65, 1.0];
line_styles = {'--', '-', ':'}; % Line styles for different delta values

% Define value function
value_function = @(x) (x >= 0) .* (x.^alpha) - (x < 0) .* lambda .* ((-x).^alpha);

% Define weighting function
weighting_function = @(p, delta) (p.^delta) ./ ((p.^delta + (1-p).^delta).^(1/delta));

% Create x and probability vectors
x = linspace(-10, 10, 1000);  % For the value function
p = linspace(0, 1, 1000);     % For the weighting function

% Plot value function
figure;
subplot(1, 2, 1);
plot(x, value_function(x), 'b', 'LineWidth', 1.5);
title('Value Function');
xlabel('x');
ylabel('v(x)');
grid on;
axis tight;

% Plot weighting function
subplot(1, 2, 2);
hold on;
for i = 1:length(delta_values)
    delta = delta_values(i);
    plot(p, weighting_function(p, delta), line_styles{i}, 'LineWidth', 1.5, ...
         'DisplayName', ['\delta = ', num2str(delta)]);
end
hold off;
title('Weighting Function');
xlabel('p');
ylabel('w(p)');
legend('show', 'Location', 'Best');
grid on;
axis tight;

% Adjust figure aesthetics
set(gcf, 'Position', [100, 100, 1000, 400]); % Set figure size
